package io.github.wanggit.antrpc.commons.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class LongToDateUtil {

    private LongToDateUtil() {
        throw new IllegalStateException();
    }

    public static String toDateStr(Long value) {
        if (null == value) {
            return null;
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(value));
    }

    public static String toDateMsStr(Long value, String defaultValue) {
        if (null == value) {
            return defaultValue;
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date(value));
    }
}
